export default {
  namespaced: true,
  state: {
    list: []
  },
  getters: {
    list:(state)=>state.list,
  },
  mutations:{
    addList(state, action){
      state.list = [...state.list, action];
    },
    removeList(state, index){
      state.list.splice(index, 1);
      state.list = [...state.list];
    },
    updateList(state, {index, data}){
      state.list.splice(index, 1, data);
      state.list = [...state.list];
    }
  },
  actions: {
    // 向List中添加数据
    addList(context, data){
      context.commit('addList', data);
    },
    // 删除数据
    removeList(context, index){
      context.commit('removeList', index);
    },
    // 更新数据
    updateList(context, data){
      context.commit('updateList', data);
    }
  }
}